'use strict';
function compare(arr1,arr2){
  if(arr1<arr2){
    return -1;
  }
  else if(arr1>arr2){
    return 1;
  }
  else{
    return 0;
  }
}
function compute_median(collection) {
  let result;
  collection.sort(compare);
  if(collection.length%2==0){
     result=(collection[collection.length/2]+collection[collection.length/2-1])/2;
  }
  else{
    result=collection[(collection.length-1)/2];
  }
  console.log(result);
  return result;
}

module.exports = compute_median;
compute_median([1, 4, 6, 2, 3, 10, 9, 8, 11, 20, 19, 30]);


